import { baseAjax } from "../utils/baseAjax";
import request from '@/utils/request'

// 注册/登录
export const login = (data, successHandle) => {
  return baseAjax({
    url: '/api/user/login',
    type: 'post',
    data,
    success: successHandle
  })
}

// 退出登录
export const logout = (data, successHandle) => {
  return baseAjax({
    url: '/api/user/logout',
    type: 'post',
    data,
    success: successHandle
  })
}

// 获取验证码
export const getCaptcha = (data, successHandle, errorHandle) => {
  return baseAjax({
    url: '/api/captcha',
    type: 'post',
    data,
    success: successHandle,
    error: errorHandle
  })
}
export const postCaptcha = (data) => {
  return request({
    url: '/api/captcha',
    method: 'post',
    data,
  })
}
// 重置密码
export const resetPassword = (data, successHandle) => {
  return baseAjax({
    url: '/api/user/pwd',
    type: 'put',
    data,
    success: successHandle
  })
}
//修改密码
export const changePassword = (data, successHandle) => {
  return baseAjax({
    url: '/api/account/password',
    type: 'put',
    data,
    success: successHandle
  })
}
export const checkMobile = (data, successHandle) => {
	return baseAjax({
		url: '/api/user/verify/mobile',
		type: 'post',
		data,
		success: successHandle
	})
}
//修改个人资料
export const changeUserInfo = (data, successHandle) => {
	return baseAjax({
		url: '/api/user',
		type: 'put',
		data,
		success: successHandle
	})
}

// 用户详情
export const getUserInfo = (successHandle) => {
	return baseAjax({
		url: '/api/user/info',
		type: 'get',
		success: successHandle
	})
}
// 获取验证码
export function getCodeImg() {
  return request({
    url: `/captchaImage/commonSource`,
    method: 'get',
    timeout: 20000
  })
}
